package blazingbubble.legacy.game;

import spark.math.Vector3;
import spark.math.Matrix;
import spark.math.Vector2;
import spark.utility.Clock;

public class Cannon
{
	public static enum Direction
	{
		Left(1),
		Right(-1);

		private int value;

		private Direction(final int value)
		{
			this.value = value;
		}

		public int getValue() { return value; }
	}

	private Vector3 target = new Vector3(0, 1, 0);
	private float speed;

	public Cannon(final float speed)
	{
		this.speed = speed;
	}

	public void move(Direction direction)
	{
		Vector2 t = new Vector2(target.x, target.y);
		float rotateBy = Clock.getInstance().getElapsedSeconds() * direction.getValue() * speed;
		t.rotate(rotateBy);
		target.x = t.x;
		target.y = t.y;
//		target.x += speed * Clock.getInstance().getElapsedSeconds() * direction.getValue();
//		if(target.x * target.x > 0.95f)
//			target.x = direction.value * 0.95f;
//		target.y = (float)Math.sqrt(1 - target.x * target.x);
	}

	public float getSpeed() { return speed; }
	public void setSpeed(final float speed) { this.speed = speed; }
	public Vector3 getShootingDirection() { return new Vector3(target); }
}
